var express = require('express');
var router = express.Router();
//引入数据模型
const { userModel } = require('../modules/userModule');

router.get('/add', async function (req, res, next) {
  const data = req.query;
  const check = await userModel.find(data);
  if (check.length > 0) {
    res.send({
      message: "账号已存在",
      code: 500
    });
    return
  }

  const result = await userModel.create(data);
  if (result) {
    res.send({
      message: "注册成功",
      code: 200
    })
  }
});

module.exports = router;
